<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .box1{width: 100px;height: 100px;background: red;}
    .box2{width: 100px;height: 100px;background: green;}
    .box3{width: 100px;height: 100px;background: blue;}
  </style>
</head>
<body>
  <div class="box1" onclick=" alert('hello') " ></div>
  <div class="box2"></div>
  <div class="box3"></div>
  
  <span>
    <script>
    
      document.getElementsByClassName("box2")[0].onclick = fn;
      document.getElementsByClassName("box3")[0].onclick = fn;
      function fn(){
        alert("world");
      }
    
      alert("123");
    
    </script>
    <script src="./index.js"></script>
  </span>
</body>
</html>